package com.harmontronics.hanma.paas.paas.domain.app.service.dialect;

import com.harmontronics.hanma.paas.paas.domain.app.entity.valueobject.ViewDataBaseTypeEnum;
import com.harmontronics.hanma.paas.paas.domain.app.repository.persistence.HmDatasourceEnvRepository;
import com.harmontronics.hanma.paas.paas.domain.app.service.HmPublishedEntityModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OracleDialectService extends AbstractDialectService {

    private String URL_TEMPLATE = "jdbc:oracle:thin:@%s:%s:%s";
    @Autowired
    private HmDatasourceEnvRepository hmDatasourceEnvRepository;

    @Autowired
    private HmPublishedEntityModelService hmPublishedEntityModelService;

    @Override
    public ViewDataBaseTypeEnum getDataBaseType() {
        return ViewDataBaseTypeEnum.ORACLE;
    }

    @Override
    public List<ViewColumn> getViewColumns(Long datasourceId, String viewName) {
        return null;
    }

    @Override
    public HmDatasourceEnvRepository getHmDatasourceEnvRepository() {
        return hmDatasourceEnvRepository;
    }

    @Override
    public HmPublishedEntityModelService getHmPublishedEntityModelService() {
        return hmPublishedEntityModelService;
    }

    @Override
    protected String concatUrl(String code, String host, Integer port, String dbName) {
        return String.format(URL_TEMPLATE, host, port.toString(), dbName);
    }
}
